package day1113_2;
import java.io.*;

class Test{
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Student  cq=new Student("chuanQ","big2-6");
        ObjectOutputStream  oos=
                new ObjectOutputStream(
                        new FileOutputStream("s.obj"));//1.
        oos.writeObject(cq);//2.
        oos.close();//3.


        ObjectInputStream  ois=new ObjectInputStream(
                new FileInputStream("s.obj"));
        Student lsq=(Student) ois.readObject();
        System.out.println(lsq.name +","+  lsq.stuNo);
        ois.close();
    }
}


//序列化：  对象保存到文件中。
public class Student  implements Serializable {
    transient String name;
    String stuNo;
    Student(String n,String s){
        name=n;  stuNo=s;
    }
}







